package com.ybkj.chat.module.main.activity;

import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.ybkj.chat.R;
import com.ybkj.chat.base.BaseMvpActivity;
import com.ybkj.chat.manager.ActivityManager;
import com.ybkj.chat.module.dynamic.activity.DynamicDetailActivity;
import com.ybkj.chat.module.dynamic.adapter.DynamicAdapter;
import com.ybkj.chat.ui.dialog.PpwShare;
import com.ybkj.chat.ui.dialog.PpwShareChannel;
import com.ybkj.chat.ui.view.recyclerview.XRecyclerView;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 话题
 */

public class TopicActivity extends BaseMvpActivity {

    @BindView(R.id.rl_root)
    RelativeLayout rlroot;
    @BindView(R.id.back_iv)
    ImageView backIv;
    @BindView(R.id.rl_back)
    RelativeLayout rlBack;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.content)
    TextView content;
    @BindView(R.id.icon_topic_arrow)
    ImageView iconTopicArrow;
    @BindView(R.id.people_num)
    TextView peopleNum;
    @BindView(R.id.rl_head)
    RelativeLayout rlHead;
    @BindView(R.id.xrc_topic)
    XRecyclerView xrcTopic;

    private DynamicAdapter dynamicAdapter;
    private PpwShare mPpwShare;
    private PpwShareChannel mPpwShareChannel;

    @Override
    protected void injectPresenter() {

    }

    @Override
    protected void initTitle() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_topic;
    }

    @Override
    protected void initView() {
        initrecycle();
        initSharePop();
    }

    private void initrecycle() {
        dynamicAdapter = new DynamicAdapter(mContext);
        dynamicAdapter.addData("1");
        dynamicAdapter.addData("1");
        dynamicAdapter.addData("1");
        dynamicAdapter.addData("1");
        dynamicAdapter.addData("1");
        xrcTopic.setAdapter(dynamicAdapter);
        dynamicAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                ActivityManager.gotoActivity(mContext, DynamicDetailActivity.class);

            }
        });
        dynamicAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                switch (view.getId()) {
                    case R.id.point_menu:
                        mPpwShare.showAtLocation(rlroot, Gravity.BOTTOM, 0, 0);
                        mPpwShare.setBackgroundAlpha(mContext, 0.5f);
                        break;
                }
            }
        });
    }

    @Override
    protected void initData() {

    }


    @OnClick({R.id.back_iv, R.id.rl_back, R.id.rl_head})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back_iv:
                break;
            case R.id.rl_back:
                break;
            case R.id.rl_head:
                break;
        }
    }

    private void initSharePop() {
        mPpwShare = new PpwShare(mContext);
        mPpwShare.setOnItemClickListener(new PpwShare.OnItemClickListener() {
            @Override
            public void onItemClick(View v) {
                switch (v.getId()) {
                    case R.id.tv_cancel:
                        mPpwShare.dismiss();
                        break;

                    case R.id.tv_share:
                        mPpwShareChannel.showAtLocation(rlroot, Gravity.BOTTOM, 0, 0);
                        mPpwShareChannel.setBackgroundAlpha(mContext, 0.5f);
                        mPpwShare.dismiss();
                        break;

                    case R.id.forward:
                        mPpwShare.dismiss();
                        break;
                }

            }
        });
        mPpwShareChannel = new PpwShareChannel(mContext);
        mPpwShareChannel.setOnShareButtonCLickListener(new PpwShareChannel.OnShareButtonClickListener() {
            @Override
            public void onWechatFriendShareClick() {
            }

            @Override
            public void onQQZoneShareClick() {
            }

            @Override
            public void onSinaShareClick() {
            }

            @Override
            public void onWechatCircleShare() {
            }

            @Override
            public void onQQShareClick() {
            }
        });
    }
}
